<?php

class MyRelation implements MyObject {
	
	protected static $objectname;
	protected static $relatedobjects;
	
	public static function getRelatedFrom(MyObject $from) {
		foreach (self::$relatedobjects AS $object) {
			$fromclass = get_class($from);
			if ($fromclass != $object) {
				$relateds = $objectname::findBy($fromclass::$pkname, $from->id);				
				foreach ($relateds AS $related) {
					$pkname = $object::$pkname;
					$obj = $object::findById($related->$pkname);
					foreach ($object::getDataFields() AS $datafield) {
						$related->$datafield = $obj->$datafield
					}
				}				
				return $related;
			}
		}
	}
	

	// public function __construct($options = array("keyname"=>0,"keyval"=>0)) {
		// return self::findBy($options['keyname'], $options['keyval']);
	// }
}